<!--
* @author luguoxiang
* @date 2021-09-07
* 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  <div v-onresize="onresize" class="lg-auto-size">
    <div class="lg-auto-size-box">
      <slot v-bind="props"></slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const props = ref({
  width: 0,
  height: 0,
  el: null,
});
function onresize(e) {
  props.value = {
    width: e.clientWidth,
    height: e.clientHeight,
    el: e,
  };
}
</script>
<script lang="ts">
export default {
  name: 'LgAutoSize',
};
</script>

<style lang="less" scoped>
.lg-auto-size {
  overflow: hidden;
  flex: 1;
}
.lg-auto-size[disabled],
.lg-auto-size.gl-disabled {
  .lg-auto-size-box {
    position: unset;
    inset: unset;
  }
}
</style>
